package com.ruoyi.answer.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.answer.entity.AdminUser;
import com.ruoyi.answer.mapper.AdminUserMapper;
import com.ruoyi.answer.service.AdminUserService;
import org.springframework.stereotype.Service;

@Service
public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser> implements AdminUserService {
    public AdminUser findByUsername(String username) {
        return this.lambdaQuery().eq(AdminUser::getAccount, username).one();
    }

    public AdminUser login(String username, String passwd) {
        return this.lambdaQuery().eq(AdminUser::getAccount, username)
                .eq(AdminUser::getPassword, passwd)
                .eq(AdminUser::getStatus, "1").one();
    }

    public AdminUser findUserById(long userId) {
        //return userMapper.selectByPrimaryKey(userId);
        AdminUser appUser = new AdminUser();
        appUser.setAccount("test");
        // return userMapper.selectOne(user);
        // 这里演示就直接返回了
        appUser.setPassword("123456");
        appUser.setId(userId);
        return appUser;
    }
}
